//
//  HXQYQueryListViewController.m
//  KD
//
//  Created by 梅洋 on 16/7/28.
//  Copyright © 2016年 Whx. All rights reserved.
//

#define kJianXiBtn 16

#import "HXQYQueryListViewController.h"
#import "HXQiYeLocaleJobTableViewController.h"
#import "HXQYPictureGatherViewController.h"
#import "HXGetCorpListModel.h"
#import "HXQYQueryListBarMenuView.h"
#import "HXLeftDropdownMenu.h"

@interface HXQYQueryListViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UITextViewDelegate,UIScrollViewDelegate>{

    UILabel  * _commpanyTypeLabel;//企业类型
    UIButton * _commpanyTypeBtn;//企业类型btn
    UIView   * _commpanyBagView;//企业类型 背景视图
    UIButton * _lastSelectedBtn;
    NSInteger pageNumIndex;//分几页
}

/**顶部视图*/
@property (nonatomic,strong) UIView * topBgView;

/**搜索框*/
@property (nonatomic,strong) UITextField  * searchTextField;
@property (nonatomic,strong) HXLeftDropdownMenu * leftMenu;
@property (nonatomic,strong) HXQYQueryListBarMenuView * leftMenuView;

/**btn按钮*/
@property (nonatomic,strong) UIButton * searchBtn;

/**tableView*/
@property (nonatomic,strong) UITableView * tableView;
@property (nonatomic,strong) NSMutableArray <HXGetCorpListCorplistModel *> * dataArray;
@property (nonatomic,copy) NSString  * CorpKind;//企业类型ID


/**添加任务的背景视图*/
@property (nonatomic,strong) UIScrollView   * addCorpTaskBgView;
@property (nonatomic,copy)   NSString * CorpName;
@property (nonatomic,copy)   NSString * siteAddressStr;
@property (nonatomic,copy)   NSString * CorpUserGuid;
@property (nonatomic,copy)   NSString * CreateDate;
@property (nonatomic,assign) CLLocationCoordinate2D locationCorrrdinate;
@property (nonatomic,strong) UILabel * commpayNameLabel;
@property (nonatomic,strong) UILabel * siteAddressLabel;
@property (nonatomic,strong) UITextField * groupNameTextField;
@property (nonatomic,strong) UITextView * siteWorkContentTextView;

@property (nonatomic,strong) NSString * updateTime;

@end

@implementation HXQYQueryListViewController

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    [self.view endEditing:YES];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];
    
    if (textField.tag == 1000) {
        
        [self loadGetDatas];
    }
    return YES;
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"] && textView.tag == 10001){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [self.view endEditing:YES];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }
    
    return YES;
}
//懒加载
-(UIView *)topBgView{

    if (_topBgView == nil) {
        
        _topBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, HXSCREEN_WIDTH, 64)];
        _topBgView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_topBgView];
    }
    
    return _topBgView;
}
-(UIButton *)searchBtn{

    if (_searchBtn == nil) {
        
        _searchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.topBgView.width-56-8, 22.f, 56, 36)];
        [self.topBgView addSubview:_searchBtn];
        [_searchBtn setTitle:@"取消" forState:UIControlStateNormal];
        [_searchBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        _searchBtn.titleLabel.font = [UIFont systemFontOfSize:20];
//        _searchBtn.layer.borderWidth = 0.5f;
//        _searchBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        [_searchBtn addTarget:self action:@selector(searchBtnAct) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _searchBtn;
}
-(UITextField *)searchTextField{

    if (_searchTextField == nil) {
        
        _searchTextField = [[UITextField alloc] initWithFrame:CGRectMake(8.f, 20.f, self.topBgView.width-8.f*2-self.searchBtn.width, 40)];
        _searchTextField.borderStyle = UITextBorderStyleNone;
        _searchTextField.returnKeyType = UIReturnKeySearch;
        [self.topBgView addSubview:_searchTextField];
        _searchTextField.tag = 1000;
        _searchTextField.clearButtonMode   = UITextFieldViewModeAlways;
        _searchTextField.layer.borderWidth = 0.5;
        _searchTextField.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _searchTextField.delegate = self;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldChangeCharacters:) name:UITextFieldTextDidChangeNotification object:nil];
        _commpanyTypeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _commpanyTypeBtn.frame = CGRectMake(0, (_searchTextField.height-36)/2, 84, 36);
        [_commpanyTypeBtn setTitle:@"企业类型" forState:UIControlStateNormal];
        [_commpanyTypeBtn setBackgroundImage:[[UIImage imageNamed:@"xiala"] stretchableImageWithLeftCapWidth:5 topCapHeight:0] forState:UIControlStateNormal];
        _commpanyTypeBtn.contentMode = UIViewContentModeLeft;
        _commpanyTypeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        //        [button sizeToFit];//让按钮大小跟随内容
        // 让按钮的内容往左边偏移10
        _commpanyTypeBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);

        _searchTextField.leftView = _commpanyTypeBtn;
        _searchTextField.leftViewMode = UITextFieldViewModeAlways;
        [_commpanyTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _commpanyTypeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_commpanyTypeBtn addTarget:self action:@selector(commpanyBtnAct) forControlEvents:UIControlEventTouchUpInside];
        
        _leftMenuView = [[HXQYQueryListBarMenuView alloc] initWithFrame:CGRectMake(0, 0, 150, 180) withDataArray:self.areaOrKindArray];
        [_leftMenuView ReturnGetAreaOrKindListModel:^(HXGetAreaOrKindListModel *model) {
            [self.leftMenu dismiss];
            
            if ([model.typeValue integerValue] <= 0) {
                self.CorpKind = @"";
                [_commpanyTypeBtn setTitle:@"企业类型" forState:UIControlStateNormal];
            }else{
            
                self.CorpKind = model.typeValue;
                NSString * typeName = model.typeName;
                if (typeName.length > 4) {
                    typeName = [typeName substringToIndex:4];
                }
                [_commpanyTypeBtn setTitle:typeName forState:UIControlStateNormal];
            }
            [self loadGetDatas];
        }];
    }
    
    return _searchTextField;
}
-(UITableView *)tableView{

    if (_tableView == nil) {
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.topBgView.bottom+2.f, HXSCREEN_WIDTH, HXSCREEN_HEIGHT-self.topBgView.height-2.f) style:UITableViewStyleGrouped];
//        _tableView.backgroundColor = [UIColor redColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        self.tableView.mj_footer=[AWRefreshFooder footerWithRefreshingTarget:self refreshingAction:@selector(loadQYMoreData)];
        self.tableView.mj_footer.automaticallyChangeAlpha = YES;
        self.tableView.mj_footer.automaticallyHidden = NO;
    }
    
    return _tableView;
}
-(UIScrollView *)addCorpTaskBgView{

    if (_addCorpTaskBgView == nil) {
        
        _addCorpTaskBgView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, HXSCREEN_WIDTH, HXSCREEN_HEIGHT)];
        _addCorpTaskBgView.backgroundColor = HXCustomColor(256, 256, 256, 1);
        _addCorpTaskBgView.hidden = YES;
        _addCorpTaskBgView.contentSize = CGSizeMake(HXSCREEN_WIDTH, HXSCREEN_HEIGHT+24);
        _addCorpTaskBgView.delegate    = self;
//        //点击手势
//        UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureAct:)];
//        tapGesture.numberOfTapsRequired     = 1;
//        tapGesture.numberOfTouchesRequired  = 1;
//        [_addCorpTaskBgView addGestureRecognizer:tapGesture];
        
        [self loadCreateAddCorpTaskBgView];
    }
    
    return _addCorpTaskBgView;
}
-(NSMutableArray<HXGetCorpListCorplistModel *> *)dataArray{

    if (_dataArray == nil) {
        
        _dataArray = [[NSMutableArray alloc] init];
    }
    
    return _dataArray;
}

/**企业类型的btn点击事件*/
-(void)commpanyBtnAct{
    [self.view endEditing:YES];
    HXLeftDropdownMenu * menu = [HXLeftDropdownMenu menu];
    menu.content = _leftMenuView;
    [menu showFrom:(UIView *)_commpanyTypeBtn];
    self.leftMenu = menu;
}

/**设计加载数据*/
-(void)loadGetDatas{

    NSLog(@"_searchTextField.text---------%@  self.CorpKind----------%@",_searchTextField.text,self.CorpKind);
    pageNumIndex = 0;
    [NetworkAPI getGetCorpListWithQuery:_searchTextField.text
                           withCorpKind:self.CorpKind
                            withPageNum:pageNumIndex
                                Success:^(HXGetCorpListModel *result) {
                                    
                                    if ([result.code integerValue] == 200) {
                                        [self.dataArray removeAllObjects];
                                        [self.dataArray addObjectsFromArray:result.corplist];
                                        [self.tableView reloadData];
                                        pageNumIndex ++;
                                        if ([result.corplist count] < 10) {
                                            [self.tableView.mj_footer endRefreshingWithNoMoreData];
                                            self.tableView.mj_footer.alpha = 1.0f;
                                            return;
                                        }
                                    }else if ([result.code integerValue] == 400){
                                        //[SVProgressHUD showSuccessWithStatus:@"暂无数据!"];
                                        [self.dataArray removeAllObjects];
                                        [self.tableView reloadData];
//                                        [self.tableView.mj_footer endRefreshingWithNoMoreData];
//                                        self.tableView.mj_footer.alpha = 1.0f;
//                                        [self.tableView.mj_footer endRefreshingWithNoMoreData];
//                                        [self.dataArray removeAllObjects];
                                    }else{
                                        //[SVProgressHUD showErrorWithStatus:@"网络错误!"];
                                    }
                                    
                                }
                                failure:^(NSError *err) {
                                    [SVProgressHUD showErrorWithStatus:@"网络错误!"];

                                }];
}


-(void)loadQYMoreData{
    
    if (pageNumIndex != 0) {
        [NetworkAPI getGetCorpListWithQuery:_searchTextField.text
                               withCorpKind:self.CorpKind
                                withPageNum:pageNumIndex
                                    Success:^(HXGetCorpListModel *result) {
                                        
                                        if ([result.code integerValue] == 200) {
                                            if ([result.corplist count] == 0) {
                                                [self.tableView.mj_footer endRefreshingWithNoMoreData];
                                                self.tableView.mj_footer.alpha = 1.0f;
                                                return;
                                            }else if ([result.corplist count] < 10) {
                                                [self.dataArray addObjectsFromArray:result.corplist];
                                                [self.tableView reloadData];
                                                [self.tableView.mj_footer endRefreshingWithNoMoreData];
                                                self.tableView.mj_footer.alpha = 1.0f;
                                            }else {
                                                pageNumIndex ++;
                                                [self.dataArray addObjectsFromArray:result.corplist];
                                                [self.tableView reloadData];
                                                [self.tableView.mj_footer endRefreshing];
                                                self.tableView.mj_footer.alpha = 0;
                                            }
                                        }else if ([result.code integerValue] == 400){
                                            [self.tableView.mj_header endRefreshing];
                                            [self.tableView.mj_footer endRefreshingWithNoMoreData];
                                            self.tableView.mj_footer.alpha = 1.0f;
                                            [SVProgressHUD showSuccessWithStatus:@"已加载全部"];                                        //                                        [self.tableView.mj_footer endRefreshingWithNoMoreData];
                                            //                                        [self.dataArray removeAllObjects];
                                        }else{
                                            //[SVProgressHUD showErrorWithStatus:@"网络错误!"];
                                        }
                                        
                                    }
                                    failure:^(NSError *err) {
                                        [SVProgressHUD showErrorWithStatus:@"网络错误!"];
                                        
                                    }];
    }
    else {
        [self.tableView.mj_footer endRefreshing];
        self.tableView.mj_footer.alpha = 0.f;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.siteAddressStr = @"";
    self.CorpKind = @"";
    [[CCLocationManager shareLocation] getLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
        self.locationCorrrdinate = locationCorrrdinate;
    } withAddress:^(NSString *addressString) {
        self.siteAddressStr = addressString;
    }];
    
    //注册Textview的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewTextDidBeginEditing) name:UITextViewTextDidBeginEditingNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewTextDidEndEditing) name:UITextViewTextDidEndEditingNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewTextDidBeginEditing) name:UITextFieldTextDidBeginEditingNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewTextDidEndEditing) name:UITextFieldTextDidEndEditingNotification object:nil];

    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.addCorpTaskBgView];
    //设置SearchTextField的样式
//    self.searchTextField.borderStyle = UITextBorderStyleLine;
    self.searchTextField.placeholder = @"请输入企业名称";
}

/**添加 工作描述时 进行 上拉背景视图*/
-(void)textViewTextDidBeginEditing{

//    UITextView * textView = (UITextView *)notification.object;
    [UIView animateWithDuration:0.4 animations:^{
       
        self.addCorpTaskBgView.transform = CGAffineTransformMakeTranslation(0, -40);
        
    }];
}
-(void)textViewTextDidEndEditing{

    [UIView animateWithDuration:0.4 animations:^{
        
        self.addCorpTaskBgView.transform = CGAffineTransformIdentity;
        
    }];
}


/**
 搜索btn点击相应事件
 */
-(void)searchBtnAct{

    
    [self.view endEditing:YES];
    [self dismissViewControllerAnimated:YES completion:^{}];
}

#pragma mark -----// UITextFieldDelegate \\------
-(void)textFieldChangeCharacters:(NSNotification *)notification{

    UITextField * textField = (UITextField *)notification.object;
    if (textField.tag == 1000) {
        if (textField.text.length <= 0) {
            [self.dataArray removeAllObjects];
            [self.tableView reloadData];
        }else{
        
            [self loadGetDatas];
        }
    }
}

#pragma mark -----// UITableViewDataSource \\-----
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return self.dataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        
        cell.backgroundColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont systemFontOfSize:14];
    }
    
    cell.textLabel.text = self.dataArray[indexPath.section].CorpName;
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 2.f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 1.f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 48.f;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    HXGetCorpListCorplistModel * model = self.dataArray[indexPath.section];
    
    [LTAlertView showTitle:model.CorpName message:@"确定选择?" ButtonTitles:@[@"取消",@"确定"] OnTapBlock:^(LTAlertView *alert, NSInteger num) {
        if (num == 1) {

            self.CorpName     = model.CorpName;
            self.CorpUserGuid = model.CorpUserGuid;
            [self loadCreateAddCorpTaskBgViewFuZhi];
            
            self.addCorpTaskBgView.hidden = NO;
//            [self flipView:self.addCorpTaskBgView direction:YES];
        }
    }];
}

/**布局添加任务的背景视图*/
-(void)loadCreateAddCorpTaskBgView{

    //公司名称
    _commpayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(8.f, 56.f, self.addCorpTaskBgView.width-8.f*2, 36)];
    [self.addCorpTaskBgView addSubview:_commpayNameLabel];
//    _commpayNameLabel.layer.borderWidth = 0.5;
//    _commpayNameLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _commpayNameLabel.numberOfLines     = 0;
    
    //当前位置
    _siteAddressLabel = [[UILabel alloc] initWithFrame:CGRectMake(8.f, _commpayNameLabel.bottom+16.f, _commpayNameLabel.width, 36)];
    _siteAddressLabel.numberOfLines = 0;
    [self.addCorpTaskBgView addSubview:_siteAddressLabel];
    _siteAddressLabel.font = [UIFont systemFontOfSize:14];
    
    //时间
    UILabel * datelabel = [[UILabel alloc] initWithFrame:CGRectMake(8.f, _siteAddressLabel.bottom+10.f, _commpayNameLabel.width, 21)];
    datelabel.font = [UIFont systemFontOfSize:14];
    [self.addCorpTaskBgView addSubview:datelabel];
    [NetworkAPI getServerDateSuccess:^(HXServerDateModel *result) {
        if ([result.code integerValue] == 200) {
            datelabel.text = [NSString stringWithFormat:@"创建时间:%@",result.ServerDate];
            self.CreateDate = result.ServerDate;
            
            //将列表时间转化为Date数据
            NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
            [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *netTimeDate = [dateFormatter dateFromString:result.ServerDate];
            //能修改的时间
            //将现在时间转换成工作日
            NSDate * updateDate;
            NSTimeInterval oneDay = 24*60*60*1.0;
            updateDate = [netTimeDate initWithTimeIntervalSinceNow:+oneDay];
            _updateTime = [dateFormatter stringFromDate:updateDate];
        }
    } failure:^(NSError *err) {
        
    }];
    
    
    
    
    //小组
    _groupNameTextField = [[UITextField alloc] initWithFrame:CGRectMake(8.f, datelabel.bottom+8.f, datelabel.width, 32)];
    _groupNameTextField.placeholder = @"请输入小组名称";
    [self.addCorpTaskBgView addSubview:_groupNameTextField];
    _groupNameTextField.returnKeyType = UIReturnKeyDone;
    _groupNameTextField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _groupNameTextField.layer.borderWidth = 0.5f;
    UILabel * lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 64, 32)];
    lable.text = @"小组名称:";
    lable.font = [UIFont systemFontOfSize:13];
    lable.textAlignment = NSTextAlignmentCenter;
    _groupNameTextField.leftView = lable;
    _groupNameTextField.leftViewMode = UITextFieldViewModeAlways;
    _groupNameTextField.tag = 1001;
    _groupNameTextField.font = [UIFont systemFontOfSize:14];
    _groupNameTextField.delegate = self;
    
    //工作描述
    UILabel * siteWorkContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(8.f, _groupNameTextField.bottom+10.f, _groupNameTextField.width, 18)];
    [self.addCorpTaskBgView addSubview:siteWorkContentLabel];
    siteWorkContentLabel.text      = @"请在下面输入框填写工作内容";
    siteWorkContentLabel.font = [UIFont systemFontOfSize:13];
    siteWorkContentLabel.textColor = [UIColor lightGrayColor];
    
    //textview
    _siteWorkContentTextView = [[UITextView alloc] initWithFrame:CGRectMake(8.f, siteWorkContentLabel.bottom+8.f, siteWorkContentLabel.width, 150)];
    [self.addCorpTaskBgView addSubview:_siteWorkContentTextView];
    _siteWorkContentTextView.layer.borderWidth = 0.5f;
    _siteWorkContentTextView.font = [UIFont systemFontOfSize:14];
    _siteWorkContentTextView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _siteWorkContentTextView.delegate  = self;
    _siteWorkContentTextView.returnKeyType = UIReturnKeyDone;
    _siteWorkContentTextView.tag       = 10001;

    //UIButton
    UIButton * xiayeBtn = [[UIButton alloc] initWithFrame:CGRectMake(8.f, _siteWorkContentTextView.bottom+16.f, _siteWorkContentTextView.width, 36)];
    [self.addCorpTaskBgView addSubview:xiayeBtn];
    [xiayeBtn setTitle:@"完成,填写详情" forState:UIControlStateNormal];
    [xiayeBtn addTarget:self action:@selector(xiayeBtnAct:) forControlEvents:UIControlEventTouchUpInside];
    [xiayeBtn setBackgroundImage:[UIColor imageWithColor:[UIColor blueColor]] forState:UIControlStateNormal];
    [xiayeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    xiayeBtn.layer.cornerRadius = 4.f;
    xiayeBtn.layer.masksToBounds = YES;
    xiayeBtn.tag = 10;
    
    UIButton * canleBtn = [[UIButton alloc] initWithFrame:CGRectMake(8.f, xiayeBtn.bottom + 10.f, xiayeBtn.width, 36)];
    [self.addCorpTaskBgView addSubview:canleBtn];
    [canleBtn setTitle:@"取消,重新选择" forState:UIControlStateNormal];
    [canleBtn addTarget:self action:@selector(xiayeBtnAct:) forControlEvents:UIControlEventTouchUpInside];
    [canleBtn setBackgroundImage:[UIColor imageWithColor:[UIColor lightBLue]] forState:UIControlStateNormal];
    [canleBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    canleBtn.layer.cornerRadius = 4.f;
    canleBtn.layer.masksToBounds = YES;
    canleBtn.tag = 11;
}

/**点击完成之后*/
-(void)xiayeBtnAct:(UIButton *)sender{
    if (sender.tag == 11) {
        [self.view endEditing:YES];
        self.addCorpTaskBgView.hidden = YES;
    }else if (sender.tag == 10){
    
        NSString * SiteWorkContent = _siteWorkContentTextView.text;
        if (SiteWorkContent.length <= 0) {
            SiteWorkContent = @"";
        }
        NSString * groupName = _groupNameTextField.text;
        if (groupName == nil) {
            
            groupName = @"";
        }
        
        [SVProgressHUD showWithStatus:@"正在跳转下一个页面,请稍后..."];
        
        [NetworkAPI getAddCorpTaskWithSiteName:self.CorpName
                                   withSiteAdd:self.siteAddressStr
                           withSiteWorkContent:SiteWorkContent
                                    withpointX:self.locationCorrrdinate.latitude
                                    withpointY:self.locationCorrrdinate.longitude
                                   withKeyGuid:self.CorpUserGuid
                                 withGroupName:groupName
                                withCreateDate:self.CreateDate
                                withUpdateDate:_updateTime
                                       Success:^(HXCreatePunishModel *result) {
                                           
                                           if ([result.code integerValue] == 200) {
                                               HXQYPictureGatherViewController * qyVc = [[HXQYPictureGatherViewController alloc] initWithCompanyName:self.CorpName withPushType:QY_JUMP_QUERYRESULT withTaskId:result.taskid withSiteWorkContent:SiteWorkContent withGroupName:groupName];
                                               [self.qyLJVc.navigationController pushViewController:qyVc animated:YES];
                                               [self dismissViewControllerAnimated:YES completion:^{
                                                   [SVProgressHUD dismiss];
                                               }];
                                               
                                           }
                                           
                                       } failure:^(NSError *err) {
                                           [SVProgressHUD dismiss];
                                           [SVProgressHUD showErrorWithStatus:@"对不起,网络错误!"];
                                       }];
    }
}

/**进行赋值*/
-(void)loadCreateAddCorpTaskBgViewFuZhi{

    //设置公司名称
    NSString * companyStr = [NSString stringWithFormat:@"企业名称: %@",self.CorpName];
    NSMutableAttributedString * commpanyAttributeStr = [[NSMutableAttributedString alloc] initWithString:companyStr];
    [commpanyAttributeStr addAttribute:NSFontAttributeName
                                 value:[UIFont fontWithName:@"Helvetica-Bold" size:16]
                                 range:NSMakeRange(5, commpanyAttributeStr.length-5)];
    [commpanyAttributeStr addAttribute:NSFontAttributeName
                                 value:[UIFont systemFontOfSize:14]
                                 range:NSMakeRange(0, 5)];
    CGFloat companyHeight = [companyStr heightWithFont:[UIFont systemFontOfSize:18] withinWidth:HXSCREEN_WIDTH-8.f*2-8.f*3];
    companyHeight = companyHeight > 36 ? companyHeight : 36;
    CGRect oldCommapyFrame      = _commpayNameLabel.frame;
    oldCommapyFrame.size.height = companyHeight;
    _commpayNameLabel.frame     = oldCommapyFrame;
    _commpayNameLabel.attributedText    = commpanyAttributeStr;
    
    if (self.siteAddressStr.length <= 0) {
        
        self.siteAddressStr = [[NSUserDefaults standardUserDefaults] objectForKey:CCLastAddress];
    }
    if (self.locationCorrrdinate.latitude == 0) {
        
        NSUserDefaults *standard = [NSUserDefaults standardUserDefaults];
        self.locationCorrrdinate = CLLocationCoordinate2DMake([standard floatForKey:CCLastLatitude],[standard floatForKey:CCLastLongitude]);
    }
//    CGRect addressOldFrame = _siteAddressLabel.frame;
//    addressOldFrame.size.height =
    _siteAddressLabel.text = [NSString stringWithFormat:@"当前位置:%@",self.siteAddressStr];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
